﻿using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MedicalAdviser.DAL.Acessing;

namespace MedicalAdviser.DAL
{
    public class DrugContext
    {
        //private static ProceduresDrugs _singleton;
        //public static ProceduresDrugs Context()
        //{
        //    if(_singleton == null)
        //        _singleton = new ProceduresDrugs();

        //    return _singleton;
        //}

        public static ProceduresDrugs Context()
        {
            return (ProceduresDrugs) GetCurrentUnitOfWork<EfUnitOfWork>().Context;
        }

        public static void SaveContext()
        {
            GetCurrentUnitOfWork<EfUnitOfWork>().Commit();
        }


        public static TUnitOfWork GetCurrentUnitOfWork<TUnitOfWork>()
           where TUnitOfWork : IUnitOfWork
        {
            return (TUnitOfWork)UnitOfWork.Current;
        }


    }
}
